import axios from '../utils/axios'

module.exports = async (ctx) => {
  // 获取地址栏中的请求参数
  const {
    city,
    keyword
  } = ctx.query
  const {
    status,
    data: {
      count,
      pois
    }
  } = await axios.get('http://cp-tools.cn/search/resultsByKeywords', {
    params: {
      city,
      keyword
    }
  })
  ctx.body = {
    count: status === 200 ? count : 0,
    pois: status === 200 ? pois : []
  }
}
